package com.yzycoc.hamster.demo.time202507.image;

import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.RandomUtil;
import com.yzycoc.hamster.demo.common.ImageDownloadUtil;
import com.yzycoc.hamster.demo.time202507.info.GalleryParser;
import lombok.extern.slf4j.Slf4j;

/**
 * 创建时间： 2025/7/4
 *
 * @version 1.0
 **/
@Slf4j
public class GaillImage {


    public static void main(String[] args) {
        ImageDownloadUtil imageDownloadUtil = new ImageDownloadUtil("/saveImage");
        GalleryParser galleryParser = new GalleryParser();
        // 模拟带 cookie 和 header 的请求
        for (int i = 21; i < 50; i++) {
            int finalI = i;
            new Thread(() -> {
                System.out.println("开始执行");
                new GalleryParser().getData(finalI + 1, imageDownloadUtil);
            }).start();
            int millis = RandomUtil.randomInt(1000 * 10, 1000 * 120); // 10s - 240s
            int seconds = millis / 1000;
            log.info("准备睡眠：" + seconds + " 秒");

            for (int j = seconds; j > 0; j--) {
                System.out.print("\r倒计时：" + j + " 秒   ");
                System.out.flush();
                ThreadUtil.sleep(1000);
            }

        }
    }
}
